﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SEG.Model;
using SEG.UI.Control.Presenters;
using Common.Model;

namespace SEG.UI.Control.Views
{
    /// <summary>
    /// Interaction logic for AsignarPermisosAGrupoView.xaml
    /// </summary>
    public partial class AsignarPermisosAGrupoView : Window, IAsignarPermisosAGrupoView
    {

        AsignarPermisosAGrupoPresenter _presenter;
        public AsignarPermisosAGrupoPresenter Presenter
        {
            get { return _presenter; }
            set { _presenter = value; }
        }
        ViewEntity _grupoViewEntity;
        public ViewEntity GrupoViewEntity
        {
            get { return _grupoViewEntity; }
            set { _grupoViewEntity = value; }
        }

        Grupo _grupo;
        public Grupo Grupo
        {
            get { return _grupo; }
            set
            {
                _grupo = value;
                this.DataContext = _grupo;
            }
        }

        public AsignarPermisosAGrupoView()
        {
            InitializeComponent();
        }

        public AsignarPermisosAGrupoView(ViewEntity grupo)
        {
            InitializeComponent();

            GrupoViewEntity = grupo;

            this.InitializePresenter();
        }

        private void InitializePresenter()
        {
            Presenter = new AsignarPermisosAGrupoPresenter(this, GrupoViewEntity);
        }

        private void Cancelar_Click(object sender, RoutedEventArgs e)
        {
            this.Presenter.Cancelar();
            this.Close();
        }

        private void Aceptar_Click(object sender, RoutedEventArgs e)
        {
            var rta = this.Presenter.Aceptar();
            if (rta)
            {
                this.Close();
            }
        }
    }
}
